<?php
namespace app\houtai\controller;
use app\houtai\controller\Base;
use think\Db;
use think\Session;
use app\houtai\controller\File;
class annx extends Base
{
    public function lst()
    {	
        $data=db('annx')->order('id desc')->paginate(8);
        $this->assign('annxpic',$data);
        return view();
    }
    public function del()
    {
        $id=input('id');
        $datas=db('annx')->where('id',$id)->find();
        $ss=str_replace(YM,"./uploads/",$datas['picsrc']);
        $file= new File();
        $file->delete_file(str_replace(YM,"./public/uploads/",$datas['picsrc']));
        $res=db('annx')->delete($id);
        if($res){
            return json_encode([
                'status'=>1,
                ]);
        }else{
            return json_encode([
                'status'=>0,
                ]);
        }
    }
    public function delall()
    {
        $thumb= explode(',',input('thumb'));//explode 字符串分割为数组
        $id=input('id');
        $file=new File();
        $file->delete_file_all(str_replace(YM,"./public/uploads/",$thumb));
        $res=db('annx')->delete($id);
        if($res){
            return json_encode([
                'status'=>1,
                ]);
        }else{
             return json_encode([
                'status'=>0,
                ]);
        }
    }
}
